///**
//* @CopyRight tstudy.com.cn
//* @author wuyahui
//* @E-mail wuyahui0124505@163.com
//* @version 1.0.0
//* @Date  2015年4月3日 下午1:03:40
//*/
//package com.tstudy.laoshibang.community;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import org.androidannotations.annotations.AfterViews;
//import org.androidannotations.annotations.EFragment;
//import org.androidannotations.annotations.ViewById;
//import org.androidannotations.annotations.res.StringRes;
//import org.apache.http.Header;
//
//import com.handmark.pulltorefresh.library.PullToRefreshBase;
//import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
//import com.handmark.pulltorefresh.library.PullToRefreshListView;
//import com.loopj.android.http.ResponseHandlerInterface;
//import com.tstudy.laoshibang.R;
//import com.tstudy.laoshibang.base.BaseActivity;
//import com.tstudy.laoshibang.base.BaseApplication;
//import com.tstudy.laoshibang.base.BaseFragment;
//import com.tstudy.laoshibang.base.BaseOnScrollListener;
//import com.tstudy.laoshibang.base.BaseOnScrollListener.LoadMoreCallBack;
//import com.tstudy.laoshibang.base.CONSTANT;
//import com.tstudy.laoshibang.base.CONSTANT.LoadType;
//import com.tstudy.laoshibang.base.HttpManager;
//import com.tstudy.laoshibang.community.CommentListAdapter.AdapterCallBack;
//import com.tstudy.laoshibang.mode.Comment;
//import com.tstudy.laoshibang.mode.Community;
//import com.tstudy.laoshibang.mode.User;
//import com.tstudy.laoshibang.mode.response.BaseResponse;
//import com.tstudy.laoshibang.mode.response.CommentListResponse;
//import com.tstudy.laoshibang.mode.response.CommunityDetailResponse;
//import com.tstudy.laoshibang.mode.response.CommunityListResponse;
//import com.tstudy.laoshibang.utils.CommonUtil;
//import com.tstudy.laoshibang.utils.LogUtil;
//
//import android.annotation.SuppressLint;
//import android.app.Dialog;
//import android.graphics.drawable.ColorDrawable;
//import android.os.Bundle;
//import android.os.Handler;
//import android.support.v4.app.Fragment;
//import android.view.Gravity;
//import android.view.KeyEvent;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.View.OnClickListener;
//import android.view.ViewGroup;
//import android.view.Window;
//import android.view.WindowManager;
//import android.widget.EditText;
//import android.widget.ImageView;
//import android.widget.ListView;
//import android.widget.RelativeLayout;
//import android.widget.TextView;
//import android.widget.TextView.OnEditorActionListener;
//@SuppressLint({ "InflateParams", "CutPasteId" })
//@SuppressWarnings({ "deprecation", "unused" })
//@EFragment(R.layout.comment_list)
//public class CommentListFragment extends BaseFragment{
//	final static String TAG = "comment_list";
//	public CommentListFragment() {
//		super();
//	}
//	
//	@ViewById(R.id.comment_list_root)
//	RelativeLayout mRootLayout;
//	
//	@ViewById(R.id.comment_list_progress)
//	RelativeLayout mProgressLayout;
//	
//	@ViewById(R.id.comment_list_list)
//	PullToRefreshListView mPullToRefreshListView;
//	
//	BaseOnScrollListener mBaseOnScrollListener;
//	LoadType mLoadType;
//	
//	boolean mIsFirstLoad = true;
//	Handler mHandler;
//	LayoutInflater mInflater;
//	CommentListAdapter mCommentListAdapter;
//	int mCurrentPosition = 0;
//	List<View> mViewList = new ArrayList<View>();
//	List<Comment> mComments = new ArrayList<Comment>();
//	@StringRes(R.string.select_all)
//	String mSelectAllStr;
//	int mSelectAllKey = -1;
//	int mCommunityId;
////	int mPosition;
//
//	public static void add(int containerViewId,int communityId) {
//		Bundle args = new Bundle();
//		args.putInt(CONSTANT.ARGS.FRAGMENT_ID, containerViewId);
//		args.putInt(CONSTANT.ARGS.COMMUNITY_ID, communityId);
//		Fragment fragment = Fragment.instantiate(BaseApplication.mContext,CommunityDetailFragment_.class.getName(),args);
//		((BaseActivity) BaseApplication.mCurrentActivity).add(containerViewId, fragment, TAG);
//	}
//	@Override
//	public void onCreate(Bundle savedInstanceState) {
//		mHandler = new Handler();
//		super.onCreate(savedInstanceState);
//	}
//	@Override
//	public View onCreateView(LayoutInflater inflater, ViewGroup container,
//			Bundle savedInstanceState) {
//		mInflater = inflater;
//		super.onCreateView(inflater, container, savedInstanceState);
//		LogUtil.d("--mBaseLayout==" + mRootLayout);
//		mIsFirstLoad = mRootLayout == null;
//		if (mRootLayout != null) {
//			((ViewGroup) mRootLayout.getParent()).removeAllViews();
//		}
//		return mRootLayout;
//	}
//	
//	@AfterViews
//	public void initView(){
//		if (mIsFirstLoad) {
//			mCommentListAdapter = new CommentListAdapter();
//			mPullToRefreshListView.setAdapter(mCommentListAdapter);
//			mCommentListAdapter.setAdatperCallBack(new AdapterCallBack() {
//				@Override
//				public void onAvatarClick(String userNo) {
////					CommentDetailFragment.add(mFragmentId,userNo);
//				}
//
//				@Override
//				public void onDeleteClick(int commentId, int position) {
//					// TODO Auto-generated method stub
//					String title = BaseApplication.getResString(R.string.delete_comment_dialog_title);
//					String content = BaseApplication.getResString(R.string.delete_comment_dialog_content);
//					showDeleteCommentDialog(commentId,position,title, content);
//				}
//
//				@Override
//				public void onCommentClick(User fromUser,int commentId,int position) {
//					// TODO Auto-generated method stub
//				}
//			});
//			mPullToRefreshListView.getRefreshableView().addHeaderView(mHeaderLayout);
//			mLoadType = LoadType.load_first;
//			mHandler.postDelayed(new Runnable() {
//				@Override
//				public void run() {
//					getCommentList();
//					
//				}
//			}, CONSTANT.LOAD_DATA_DELAY_TIME);
//			mBaseOnScrollListener = new BaseOnScrollListener(new LoadMoreCallBack() {
//				@Override
//				public void loadMore() {
//					mLoadType = LoadType.load_more;
//					getCommentList();
//				}
//			});
//			mPullToRefreshListView.setOnScrollListener(mBaseOnScrollListener);
//			mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
//				@Override
//				public void onRefresh(PullToRefreshBase<ListView> refreshView) {
//					mLoadType = LoadType.load_refresh;
//					getCommentList();
//				}
//			});
//		}
//	}
//	RelativeLayout mHeaderLayout;
//	ImageView mUserAvatar;
//	TextView mUserName;
//	TextView mCreateTime;
//	TextView mTitle;
//	TextView mContent;
//	RelativeLayout mImgLayout;
//	TextView mCommentAction;
//	TextView mLoveAction;
//	TextView mShareAction;
//	TextView mDeleteAction;
//	
//	Dialog mDeleteDialog;
//	@SuppressLint("InflateParams")
//	public void showDeleteCommunityDialog(String title,String content){
//		RelativeLayout dialogView = (RelativeLayout) mInflater.inflate(R.layout.common_alert_dialog, null);
//		if(mDeleteDialog != null && mDeleteDialog.isShowing()){
//			return;
//		}
//		mDeleteDialog = buildAlertDialog(dialogView,CommonUtil.dip2px(80));
//		TextView titleTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_title);
//		final TextView contentTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_content);
//		TextView cancelTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_cancel);
//		TextView confirmTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_confirm);
//		confirmTxt.setText(R.string.common_delete);
//		titleTxt.setText(title);
//		contentTxt.setText(content);
//		confirmTxt.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				mDeleteDialog.dismiss();
//				deleteCommunity();
//			}
//		});
//		cancelTxt.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				mDeleteDialog.dismiss();
//			}
//		});
//		mDeleteDialog.show();
//	}
//	
//	Dialog mDeleteCommentDialog;
//	@SuppressLint("InflateParams")
//	public void showDeleteCommentDialog(final int commentId,final int position,String title,String content){
//		RelativeLayout dialogView = (RelativeLayout) mInflater.inflate(R.layout.common_alert_dialog, null);
//		if(mDeleteCommentDialog != null && mDeleteCommentDialog.isShowing()){
//			return;
//		}
//		mDeleteCommentDialog = buildAlertDialog(dialogView,CommonUtil.dip2px(80));
//		TextView titleTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_title);
//		final TextView contentTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_content);
//		TextView cancelTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_cancel);
//		TextView confirmTxt = (TextView) dialogView.findViewById(R.id.common_alert_dialog_confirm);
//		confirmTxt.setText(R.string.common_delete);
//		titleTxt.setText(title);
//		contentTxt.setText(content);
//		confirmTxt.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				mDeleteCommentDialog.dismiss();
//				deleteComment(commentId,position);
//			}
//		});
//		cancelTxt.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				mDeleteCommentDialog.dismiss();
//			}
//		});
//		mDeleteCommentDialog.show();
//	}
//	
//	/**
//	 * 微课点赞
//	 * @param activeId
//	 * @param type
//	 * @param isPraise
//	 */
//	private void loveAction(final Community community,int type,final int isPraise){
//		BaseListJsonHandler<CommunityListResponse> response = new BaseListJsonHandler<CommunityListResponse>() {
//			public void onStart() {
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, CommunityListResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					int count = community.isPraise==1?community.praiseNum-1:community.praiseNum +1;
//					mLoveAction.setText(count+"");
//				}
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					CommunityListResponse errorResponse) {
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected CommunityListResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
////				afterLoading();
//				return mGson.fromJson(rawJsonData,CommunityListResponse.class);
//			}
//		};
//		HttpManager.getInstance().loveAction(BaseApplication.mUserNo, type, community.tcId, isPraise, response);
//	}
//	
//	
//
//	private void getCommentList(){
//		if (mIsLoading) {
//			return ;
//		}
//		if (mLoadType == LoadType.load_more) {
//			start += pageSize;
//			limit += pageSize;
//		}else{
//			start = 0;
//			limit = pageSize;
//		}
//		mIsLoading = true;
//		BaseListJsonHandler<CommentListResponse> response = new BaseListJsonHandler<CommentListResponse>() {
//			public void onStart() {
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, CommentListResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					if (response.getData() != null) {
//						List<Comment> list = response.getData().getList();
//						if (list != null) {
//							mComments.addAll(list);
//						}
//						mCommentListAdapter.setData(mComments);
//					}
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					CommentListResponse errorResponse) {
//				afterLoading();
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected CommentListResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
////				afterLoading();
//				return mGson.fromJson(rawJsonData,CommentListResponse.class);
//			}
//		};
//		HttpManager.getInstance().getCommentList(BaseApplication.mUserNo, mCommunityId, start,limit,null,null,response);
//	}
//	
//	private void deleteCommunity(){
//		BaseListJsonHandler<BaseResponse> response = new BaseListJsonHandler<BaseResponse>() {
//			public void onStart() {
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, BaseResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					backAction(mFragmentId);
////					EventBus.getDefault().post(Integer.valueOf(mPosition));
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					BaseResponse errorResponse) {
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected BaseResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
////				afterLoading();
//				return mGson.fromJson(rawJsonData,BaseResponse.class);
//			}
//		};
//		HttpManager.getInstance().deleteCommunity(BaseApplication.mUserNo, mCommunityId, response);
//	}
//	private void createComment(String content,String toUserNo){
//		BaseListJsonHandler<BaseResponse> response = new BaseListJsonHandler<BaseResponse>() {
//			public void onStart() {
//				if (mLoadType == LoadType.load_first) {
//					showProgressBar(mProgressLayout);
//				}
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, BaseResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					BaseResponse errorResponse) {
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected BaseResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
////				afterLoading();
//				return mGson.fromJson(rawJsonData,BaseResponse.class);
//			}
//		};
//		HttpManager.getInstance().createComment(BaseApplication.mUserNo, toUserNo, mCommunityId, content, response);
//	}
//	private void deleteComment(int commentId,final int position){
//		BaseListJsonHandler<BaseResponse> response = new BaseListJsonHandler<BaseResponse>() {
//			public void onStart() {
//				if (mLoadType == LoadType.load_first) {
//					showProgressBar(mProgressLayout);
//				}
//			}
//			@Override
//			public void onSuccess(int statusCode, Header[] headers,
//					String rawJsonResponse, BaseResponse response) {
//				super.onSuccess(statusCode, headers, rawJsonResponse, response);
//				if (CommonUtil.responseSuccess(response)) {
//					mComments.remove(position);
//					mCommentListAdapter.setData(mComments);
//					int selection = Math.min(position, mComments.size());
//					if (selection != 0) {
//						mPullToRefreshListView.getRefreshableView().setSelection(position);
//					}
//				}
//				afterLoading();
//			}
//			@Override
//			public void onFailure(int statusCode, Header[] headers,
//					Throwable throwable, String rawJsonData,
//					BaseResponse errorResponse) {
//				super.onFailure(statusCode, headers, throwable, rawJsonData, errorResponse);
//			}
//			@Override
//			protected BaseResponse parseResponse(String rawJsonData, boolean isFailure)
//					throws Throwable {
////				afterLoading();
//				return mGson.fromJson(rawJsonData,BaseResponse.class);
//			}
//		};
//		HttpManager.getInstance().deleteComment(BaseApplication.mUserNo, commentId, response);
//	}
//
//	public void afterLoading(){
//		mIsLoading = false;
//		hideProgressBar(mProgressLayout);
//		if(mLoadType == LoadType.load_more){
//			if (mBaseOnScrollListener.mIsEnd) {
//				mPullToRefreshListView.endLoadMore();
//			}else{
//				mPullToRefreshListView.stopLoadMore();
//			}
//		}
//		if(mPullToRefreshListView != null){
//			new Handler().postDelayed(new Runnable() {
//				@Override
//				public void run() {
//					if(mPullToRefreshListView != null){
//						mPullToRefreshListView.onRefreshComplete();
//						LogUtil.d("--onRefreshComplete afterloading");
//					}
//				}
//			}, 1000);
//		}
//	
//	}
//	Dialog mSearchDialog;
//	String mWord;
//	EditText mSearchExt;
//	public void showSearchDialog(){
//		RelativeLayout shareLayout = (RelativeLayout) mInflater.inflate(R.layout.search_pop, null);
//		if(mSearchDialog != null && mSearchDialog.isShowing()){
//			return;
//		}
//		mSearchDialog = new Dialog(BaseApplication.mCurrentActivity, R.style.fullscreendialog);
//		mSearchDialog.setCanceledOnTouchOutside(true);
//		mSearchDialog.setContentView(shareLayout);
//		ImageView back = (ImageView) shareLayout.findViewById(R.id.search_pop_back);
//		mSearchExt = (EditText)shareLayout.findViewById(R.id.search_pop_ext);
////		searchExt.setHint(R.string.search_product_hint);
//		mSearchExt.setText(mWord);
//		mSearchExt.setOnEditorActionListener(new OnEditorActionListener() {
//			@Override
//			public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
////				if(actionId == EditorInfo.IME_ACTION_SEARCH){
//				if (event == null) {
////					searchAction();
//				}
////				}
//				return false;
//			}
//		});
//		back.setOnClickListener(new OnClickListener() {
//			@Override
//			public void onClick(View v) {
//				mSearchDialog.dismiss();
//			}
//		});
//		Window window = mSearchDialog.getWindow();
//		window.setBackgroundDrawable(new ColorDrawable(0x00000000));
//		window.setLayout(BaseApplication.mScreenWidth, BaseApplication.mScreenHeight);
//		window.setGravity(Gravity.TOP);
//		window.setWindowAnimations(R.style.look_share_show);
//		window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
//				| WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
//		mSearchDialog.show();
//		window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN| WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
////		mHandler.postDelayed(new Runnable() {
////			@Override
////			public void run() {
////				showSoftKeyBoard(searchExt, true);
////			}
////		}, CONSTANT.LOAD_DATA_DELAY_TIME);
//	}
//	@Override
//	public void clear() {
//		// TODO Auto-generated method stub
//	}
//
//	@Override
//	public void initArgs(Bundle args) {
//		if (args != null) {
//			mFragmentId = args.getInt(CONSTANT.ARGS.FRAGMENT_ID);
//			mCommunityId = args.getInt(CONSTANT.ARGS.COMMUNITY_ID);
//		}
//	}
//
//}
